<template>
  <div class="stockCountDaily">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span style="line-height: 36px;">库存统计</span>
      </div>
      <s-table
        :table="table"
        @http="tableWatch">
        <el-form-item slot="multiSelect" label="多选操作" prop="multiSelect" v-if="table.multiSelect">
          <el-row>
            <el-col :span="8">
              <el-button size="small" type="info" @click="tableExport('')">多选导出</el-button>
            </el-col>
          </el-row>
        </el-form-item>
        <el-form-item label="产品编码" prop="goodsBh">
          <el-input type="text"
                    class="input"
                    v-model="autoVue_table_goodsBh"
                    placeholder="产品编码" spellcheck="false" auto-capitalize="off" auto-complete="off"
                    auto-correct="off"></el-input>
        </el-form-item>
        <el-form-item label="产品名称" prop="goodsMc">
          <el-input type="text"
                    class="input"
                    v-model="autoVue_table_goodsMc"
                    placeholder="产品名称" spellcheck="false" auto-capitalize="off" auto-complete="off"
                    auto-correct="off"></el-input>
        </el-form-item>
      </s-table>
    </el-card>
  </div>
</template>

<script>
  import {AutoVue} from '~/plugins/Tools';
  export default AutoVue({
    name: 'journaling_stockCountDaily-FEcarWms',
    head: {
      'title': '库存统计',
      'meta': [
        {'hid': 'description', 'name': 'description', 'content': '乐速科技平台 库区统计 查看库区统计信息'},
      ],
    },
    data: {
      table: {
        column: [
          { label: 'NC编码',
            prop: 'goodsNc',
            minWidth: '0px',
            search: false,
          },
          { label: '产品编码',
            prop: 'goodsBh',
            minWidth: '0px',
            search: true,
          },
          { label: '产品名称',
            prop: 'goodsMc',
            minWidth: '0px',
            search: true,
          },
          { label: '规格',
            prop: 'goodsGg',
            minWidth: '0px',
            search: false,
          },
          { label: '单位',
            prop: 'dw',
            minWidth: '0px',
            search: false,
          },
          { label: '单价',
            prop: 'je',
            minWidth: '0px',
            search: false,
          },
          { label: '产品批次',
            prop: 'hppc',
            minWidth: '0px',
            search: false,
          },
          { label: '产品等级',
            prop: 'hpdj',
            minWidth: '0px',
            search: false,
          },
          { label: '存储区数量',
            prop: 'ccqsl',
            minWidth: '0px',
            search: false,
          },
          { label: '分拣区数量',
            prop: 'jhqsl',
            minWidth: '0px',
            search: false,
          },
          { label: '总数量',
            prop: 'zsl',
            minWidth: '0px',
            search: false,
          },
          { label: '总货值',
            prop: 'zje',
            minWidth: '0px',
            search: false,
          },
        ],
        url: '/statistics/stockStatistics',
        key: 'id',
        tableColumn: 12,
      },
    },
    transition: 'slide-fade',
    methods: {
      tableExport (row) {
        let tableRef = 'table';

        let ids = [];
        if (row) {
          ids.push(row.goodsId);
        } else {
          this[tableRef].multipleSelection.forEach(item => {
            ids.push(item.goodsId);
          });
        }
        this.$confirm('您将导库存统计报表。', '确认导出？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              let option = Object.assign({}, this['autoVue_' + tableRef]);
              await this.p({
                url: '/statistics/stockStatisticsExport',
                method: 'post',
                responseType: 'blob',
                data: {
                  ids,
                  ...option,
                },
              });
            } catch (err) {
              console.log(err);
            }
          })
          .catch(_ => {
          });
      },
    },
    mounted: function () {
      this.tableWatch('table');
    },
  });
</script>
<style scoped lang="scss">
</style>
